<template>
	<view class="wrap">
			<u-form class="form">
				<u-gap height="20" bg-color="#f5f5f5"></u-gap>
				<u-form-item label="预约原因" label-width="180">
					<u-input v-model="forward.forwardReason" type="text" placeholder="请输入预约原因"/>
				</u-form-item>
				<u-form-item label="预约时间" label-width="180">
					<u-input v-model="forward.forwardTime" placeholder="请选择预约时间" :type="type" @click="show=true" :select-open="show"/>
					<u-picker mode="time" v-model="show" :params="params" @confirm="timeConfirm"></u-picker>
				</u-form-item>
			</u-form>
			<view class="form-footer">
				<u-button class="btn" type="primary" @click="submit">提交</u-button>
				<u-button class="btn" type="default" @click="cancel">关闭</u-button>
			</view>	
	</view>
</template>

<script>
	export default{
		data(){
			return{
				forward:{
					forwardReason:'',
					forwardTime:'',
				},
				show:false,
				type:'picker',
				params: {
					year: true,
					month: true,
					day: true,
					hour: true,
					minute: true,
					second: true
				},
			}
		},
		methods:{
			cancel(){
				uni.navigateBack();
			},
			timeConfirm(e){
				// console.log(e);
				this.forward.forwardTime=e.year+'-'+e.month+'-'+e.day+' '+e.hour+":"+e.minute+":"+e.second;
				// console.log(this.forward.time);
			},
			submit(){
				this.$u.api.user.forwardAdd(
				this.forward
					).then(res => {
					if(res.code == '200'){
						uni.showModal({
							title: '提示',
							content: res.msg,
							showCancel: false,
							success: function () {
								uni.navigateBack();
							}
						});
					}else{
						uni.showModal({
							title: '提示',
							content: res.msg,
							showCancel: false
						});
					}
				});
			}
		},
	}
</script>

<style>
</style>